<template>
	<view class="u-p-l-10 u-p-r-10">
		<view>
			<!-- 2.0.19支持autoBack，默认为false -->
			<u-navbar title="红领新丰党建" @rightClick="rightClick" :autoBack="true" bgColor="#aa0000">
			</u-navbar>
		</view>
		<u-gap height="1"></u-gap>
		<view>
			<!-- <ad unit-id="adunit-fcfdcc4d7095b6b1" ad-intervals="30"></ad> -->
			<!-- 轮播图 -->
			<!-- #ifndef MP-WEIXIN -->
			<!-- <u-swiper :list="swiperList" height="350"></u-swiper> -->
			<!-- #endif -->
			<u-swiper :list="swiperList" height="350"></u-swiper>
		</view>
		<view>
			<view class="rowClass">
				<u-row>
					<u-col span="4" text-align="center" v-for="(item, index) in navList" :key="index">
						<view class="u-padding-20" @tap="clickNav(item)" hover-class="hoverClass">
							<image :src="item.src" style="width: 90rpx;height: 90rpx;" mode="widthFix"></image>
							<view class="tabName">{{ item.name }}</view>
						</view>
					</u-col>
				</u-row>
			</view>
			<u-gap height="10"></u-gap>
			<!-- 中间推荐nav -->
			<!-- 			<view @click="notice">
				<u-notice-bar mode="vertical" :list="noticeList" type="primary" more-icon
				bg-color="#fff" :duration="5000" border-radius="15"></u-notice-bar>
			</view> -->
			<u-gap height="5"></u-gap>

			<view class="moreArt">
				<article-list-component :listData="artList"></article-list-component>
				<!-- 				  <u-card border="false" :title="item.title"  v-for="(item,index) in artList" :key="index" @click="clickArt(item)">
						<view class="" slot="body">
							<view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
								<view class="u-body-item-title u-line-2">{{item.content}}</view>
								<image src="https://img11.360buyimg.com/n7/jfs/t1/94448/29/2734/524808/5dd4cc16E990dfb6b/59c256f85a8c3757.jpg" mode="aspectFill"></image>
							</view>
						</view>
						<view slot="foot">
							<div style="width: 100%;">
								<div style="width: 79%; float: left;">时间：{{$u.timeFormat(item.createTime, 'yyyy年mm月dd日')}}</div>
								<div  style="width: 20%; float: right;">{{item.extend6}}</div>
							</div>
						</view>
					</u-card> -->
			</view>
		</view>
		<u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="findArtlist"
			style="height: 80rpx;line-height: 80rpx;"></u-loadmore>
		<u-back-top :scroll-top="scrollTop" top="1000"></u-back-top>
		<u-no-network></u-no-network>
	</view>
</template>

<script>
import config from "@/common/config.js" // 全局配置文件
import ArticleListComponent from '@/components/uni/article-list-component.vue';
export default {
	components: {
		ArticleListComponent
	},
	data() {
		return {
			artList: [],
			keyword: '',
			pageNum: 1,
			pageSize: 20,
			scrollTop: 0,
			houseList: [],
			swiperList: [
				{
					image: 'https://www.hzwl.online/dj//profile/upload/2025/02/16/37b82ae9-d923-4719-b4f3-e1e26afcb180.jpg',
				},
				{
					image: 'https://www.hzwl.online/dj//profile/upload/2025/02/16/457d5eb3-a8aa-4ead-a18a-9122a18f90ee.jpg',
				},
			],
			noticeList: [],
			navList: [
				{ name: "学习教育", src: "/static/img/index/cover_2022/dsbn.png", type: "0" },
				{ name: "特色党建", src: "/static/img/index/cover_2022/tsdj.png", type: "1" },
				{ name: "暖心驿站", src: "/static/img/index/cover_2022/shyk.png", type: "2" },
				{ name: "随手公益", src: "/static/img/index/cover_2022/zyfw.png", type: "3" },
				{ name: "爱心商户", src: "/static/img/index/cover_2022/axsh.png", type: "4" },
				{ name: "新新之声", src: "/static/img/index/cover_2022/xxzs.png", type: "5" }
			],
			loadStatus: 'loadmore',
			flowList: [],
			uvCode: uni.getStorageSync('uvCode')
		}
	},
	onLoad() {
		// 获取数据
		this.findArtlist();
		// this.getNoticecList();
		// 流量统计
		// this.appSysFlowInfo();
		uni.$on('findIndexHouseList', (obj) => {
			// 获取数据
			this.findArtlist(1);
		})
	},
	onUnload() {
		// 移除监听事件  
		uni.$off('findIndexHouseList');
	},
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
	onReachBottom() {
		this.loadStatus = 'loading';
		// 获取数据
		this.findArtlist()
	},
	// 下拉刷新
	onPullDownRefresh() {
		// 获取数据
		this.findArtlist(1);
		// 关闭刷新
		uni.stopPullDownRefresh();
	},
	methods: {
		location() {
			this.$u.route({
				url: 'pages/location/location',
			})
		},
		search() {
			this.$u.route({
				url: 'pages/search/search',
			})
		},
		notice() {
			this.$u.route({
				url: 'pages/notice/notice'
			})
		},
		clickArt(item) {
			this.$u.route({
				url: 'pages/center/artShow',
				params: {
					id: item.id,
					title: item.title,
					content: item.content,
					createTime: item.createTime,
				}

			});
		},
		findArtlist() {
			let url = "/api/artApi/list";
			this.$u.get(url, {
				pageNum: this.pageNum,
				pageSize: this.pageSize,
				orderByColumn: 'createTime',
				isAsc: 'desc'
			}).then(result => {
				const data = result.rows;
				if (this.pageNum > 1 && data.length < this.pageSize) {
					return this.loadStatus = 'nomore';
				}
				this.artList = data;
				console.log(this.artList, "arelist")
				++this.pageNum
				this.loadStatus = 'loadmore';
			});
		},
		findHouseList(type = 0) {
			if (type == 1) {
				this.pageNum = 1
				this.flowList = []
				this.$refs.uWaterfall.clear();
			}
			let url = "/api/houseApi/findHouseRoomList";

		},
		clickSearch() {
			this.$u.route('/pages/search/search');
			this.$u.get(url, {
				pageNum: this.pageNum,
				pageSize: this.pageSize,
				orderByColumn: 'update_time,create_time',
				isAsc: 'desc'
			}).then(result => {
				const data = result.rows;
				if (this.pageNum > 1 && data.length < this.pageSize) {
					return this.loadStatus = 'nomore';
				}
				this.atrList = data;

				++this.pageNum
				this.loadStatus = 'loadmore';
			});
		},
		clickImage(houseId) {
			this.$u.route({
				url: '/pages/detail/detail',
				params: {
					houseId: houseId
				}
			})
		},
		clickNav(item) {
			if (item.type == 0 || item.type == 1) {
				return this.$u.route({
					url: '/pages/search/searchAtrList',
					params: {
						type: item.type
					}
				});
			}
			if (item.type == 2) {
				return this.$u.route({
					url: '/pages/hearted/station',
				});
			}

			if (item.type == 3) {
				return this.$u.route({
					url: '/pages/handyWelfare/handyWelfare/handyWelfare',
				});
				// return this.$u.route({
				// 	url: '/pages/PartyHeartfelt/index',
				// });
			}

			if (item.type == 4) {
				return this.$u.route({
					url: '/pages/loveMerchant/loveMerchant',
				});
			}

			// 判断类型5需要登录
			if (item.type == 5) {
				// 获取登录状态
				const token = uni.getStorageSync('token');
				console.log(uni.getStorageSync('token'), "token")
				if (!token) {
					// 未登录跳转登录页
					return this.$u.route({
						url: '/pages/login/login'
					});
				}
				return this.$u.route({
					url: '/pages/PartyHeartfelt/index',
				});

			}
		},
		code() {

			this.$mytip.toast('请咨询作者')
		},
		// appSysFlowInfo(){
		// 	// 流量统计
		// 	let uvCode = uni.getStorageSync("uvCode");
		// 	let url = "https://sourcebyte.cn/api/flow/upFlow?type=MINI&uvCode=" + uvCode;
		// 	uni.request({
		// 	  url: url,
		// 	  method: "POST",
		// 	  success: (res) => {
		// 		uni.setStorageSync("uvCode", res.data.data);
		// 	  },
		// 	});
		// },
		// getNoticecList(){
		// 	let url = "/api/notice/findNoticeList";
		// 	this.$u.get(url,{
		// 		pageNum:1,
		// 		pageSize:50,
		// 		orderByColumn:'create_time',
		// 		isAsc:'desc'
		// 	}).then(obj => {
		// 		let data = obj.rows
		// 		data.filter(item=>{
		// 			this.noticeList.push(item.noticeTitle)
		// 		})
		// 	});
		// },
	}
}
</script>

<style lang="scss" scoped>
.nomore {
	background-color: $u-bg-color;
}

.search {
	width: 54px;
	height: 44px;

	&:active {
		background-color: $u-bg-color;
	}
}

.rowClass {
	border-radius: 8px;
	background-color: rgb(255, 255, 255);
	margin-top: 10rpx;
}

.hoverClass {
	background-color: #E4E7ED;
}

.tabName {
	font-size: 28rpx;
	color: $u-main-color;
}

.demo-warter {
	border-radius: 8px;
	margin-top: 3px;
	background-color: #ffffff;
	padding: 3px;
	position: relative;
}

.u-close {
	position: absolute;
	top: 20rpx;
	right: 20rpx;
}

.item-cover {
	font-size: 55rpx;
	color: $u-type-warning;
}

.item-title {
	font-size: 28rpx;
	color: $u-main-color;
	font-weight: bold;
	padding-top: 5rpx;
	padding-left: 10rpx;
}

.item-price {
	font-weight: normal;
	font-size: 32rpx;
	color: $u-type-warning;
}

.item-desc {
	font-weight: normal;
	font-size: 26rpx;
	color: $u-tips-color;
	padding-bottom: 5rpx;
	padding-left: 10rpx;
}

.item-tag {
	font-size: 24rpx;
	color: $u-tips-color;
	margin-top: 3px;
}

.buttom {
	.loginType {
		font-size: 14px;
		position: fixed;
		right: 30rpx;
		bottom: 300rpx;
		width: 60px;
		height: 60px;
		padding: 4px;
		cursor: pointer;
		background: #FFF;
		text-align: center;
		line-height: 60px;
		border-radius: 100%;
		-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
		box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
	}
}
</style>
